#!/bin/sh
[ $# -eq 0 ] && { echo "Usage: $0 INPUT_FILE OUTPUT_FILE WORD"; exit 1; }
grep -E '<s1>|<s2>' $1 \
| sed 's/.*<s1>\(.*\)<\/s1>/&/' \
| grep -E "<s1>.* $3[^a-z'].*<\/s1>|<s1>.* $3<\/s1>" | sed -e "s_<s1>\(.*\)[ \t]\($3\)[^a-z']\(.*\)<\/s1>_\1 <head>\2<\/head> \3_" > $2